<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            position: relative;
            margin: 50px auto;
            width: 600px;
            height: 200px;
            border: 1px solid #000;
            overflow: hidden;
        }
        .box ul{
            position: absolute;
            top: 0;
            left: 0;
            list-style: none;
            width: 300%;
            height: 100%;
        }
        .box ul li{
            float: left;
        }
        .box>ul>li>img {
            /* 去除垂直方向空隙 */
            vertical-align: top;
        }
    </style>
    <script>
        window.onload = function(){
            function $(selecter) {
                return document.querySelector(selecter)
            }
            //  移动
            var movelave = 0;
            //  定时器
            var timer = null;
            //  滚动
            function fn(){
                movelave -= 3
                if(movelave<=-1200){
                    movelave = 0
                }else{
                    $('ul').style.left = movelave + 'px'
                }
            }
            timer = setInterval(fn, 30);
            //  鼠标移入停止
            $('.box').onmouseover = function(){
                clearInterval(timer)
            }
            //  鼠标移出继续
            $('.box').onmouseout = function(){
                timer = setInterval(fn, 30);
            }
        }
    </script>
</head>
<body>
    <div class="box">
        <ul>
            <li><img src="./image/01.jpg" alt="图片"></li>
            <li><img src="./image/02.jpg" alt="图片"></li>
            <li><img src="./image/03.jpg" alt="图片"></li>
            <li><img src="./image/04.jpg" alt="图片"></li>
            <!-- 利用人眼视觉停留 -->
            <li><img src="./image/01.jpg" alt="图片"></li>
            <li><img src="./image/02.jpg" alt="图片"></li>
        </ul>
    </div>
</body>
</html>